/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.atomojo.sparql;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author alex
 */
public class OperatorExpression extends Expression {

   public enum Operator {
      Or("||"),
      And("&&");
      String value;
      Operator(String v) {
         value = v;
      }
      public String toString() {
         return value;
      }
   }
   Operator op;
   List<Expression> parts;
   
   public OperatorExpression(Operator op) {
      this.op = op;
      this.parts = new ArrayList<Expression>();
   }
   
   public Operator getOperator() {
      return op;
   }
   
   public List<Expression> getParts() {
      return parts;
   }
   
   public String toString() {
      StringBuilder builder = new StringBuilder();
      builder.append("(");
      boolean first = true;
      for (Expression exp : parts) {
         if (!first) {
            builder.append(op.toString());
         }
         first = false;
         builder.append(exp.toString());
      }
      builder.append(")");
      return builder.toString();
   }
}
